package com.wangwang.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtils {//閺冦儲婀℃潪顒佸床瀹搞儱鍙跨猾锟�
	
	static SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
	
	/**
	 * 閹跺ate鏉烆剚鍨氱�涙顑佹稉锟�
	 * @param date 鐟曚浇娴嗛幑銏㈡畱閺冦儲婀�
	 * @return 鏉╂柨娲栨潪顒佸床閸氬海娈戦弮銉︽埂鐎涙顑佹稉锟�
	 * */
	public static String dateToString(Date date){
		return sdf.format(date);
	}
	
	/**
	 * 閹跺﹤鐡х粭锔胯鏉烆剚鍨欴ate
	 * @param date 鐟曚浇娴嗛幑銏″灇閺冦儲婀￠惃鍕摟缁楋缚瑕�
	 * @return 鏉╂柨娲栨潪顒佸床閸氬海娈戦弮銉︽埂
	 * */
	public static Date stringToDate(String date){
		try {
			return sdf.parse(date);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return null;
	}
}
